﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using MCWEBSITE.BUL;
using MCWEBSITE.ENTITY;
using System.Collections.Generic;

public partial class Modules_HugKid_wucMainContent : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        BindNewProductList();
        BindSpecialProductList();
        BindBestSellingProductList();        
    }

    protected void BindSpecialProductList() {
        websiteProductTypeInfo objProductType = websiteProductTypeBUL.Load(5);
        lbSpecialProduct.Text = objProductType.TypeName;

        List<websiteProductInfo> lstSpecialProduct = websiteProductBUL.GetByLanguageAndTypeDS(5, "1", "vi-VN");//TypeID = 5: dac biet, 7: ban chay, 8: moi ve
        if (lstSpecialProduct != null && lstSpecialProduct.Count > 0) {
            ltrSpecialProductList.Text = "<ul id=\"imagesA\">";
            
            foreach (websiteProductInfo objProduct in lstSpecialProduct) {
                ltrSpecialProductList.Text += "<li><div class=\"jq-ss-crop\" style=\"overflow: hidden; height: 110px; width: 110px;\">" + 
                    "<a class=\"jq-ss-link\" target=\"_blank\" href=\"Default.aspx?Page=ProductDetails&Id=" + objProduct.ItemID + "\">" +
                    "<img src=\"" + objProduct.Image + "\"></a></div>" +
                    "<p><a href=\"Default.aspx?Page=ProductDetails&Id=" + objProduct.ItemID + "\" style=\"color:#000000;\">" 
                    + ((objProduct.ItemName.Length > 13) ? objProduct.ItemName.Substring(0, 13) + " ..." : objProduct.ItemName) 
                    + "</a></p><p class=\"price\">" + objProduct.Atribute1 + "</p></li>";//attribute1: price
            }

            ltrSpecialProductList.Text += "</ul>";
        }        
    }

    protected void BindBestSellingProductList() {
        websiteProductTypeInfo objProductType = websiteProductTypeBUL.Load(7);
        lbBestSellProduct.Text = objProductType.TypeName;
        dlBestSellingProductList.DataSource = websiteProductBUL.GetByLanguageAndTypeDS(7, "1", "vi-VN");
        dlBestSellingProductList.DataBind();
    }

    protected void BindNewProductList() {
        websiteProductTypeInfo objProductType = websiteProductTypeBUL.Load(8);
        lbNewProduct.Text = objProductType.TypeName;
        dlNewProductList.DataSource = websiteProductBUL.GetByLanguageAndTypeDS(8, "1", "vi-VN");        
        dlNewProductList.DataBind();
    }
}
